]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
AutorunManager: fix regression from the components rewrite
authorGiovanni Campagna <gcampagna@src.gnome.org>
Wed, 5 Sep 2012 00:24:56 +0000 (02:24 +0200)
committerGiovanni Campagna <gcampagna@src.gnome.org>
Wed, 5 Sep 2012 14:22:11 +0000 (16:22 +0200)
Message tray sources cannot be reused after destruction, so connect
to 'destroy' signal and clear out the previous one.
Also, fix some code paths that used the autorun manager incorrectly.

https://bugzilla.gnome.org/show_bug.cgi?id=683377

js/ui/components/autorunManager.js

index 3434e9b88b401c5d8c320171d1a1df6b841ea053..cf75cb11cdea5793dbf8874bf774c55727b1552a 100644 (file)
@@ -150,8 +150,18 @@ const AutorunManager = new Lang.Class({
         this._transDispatcher = new AutorunTransientDispatcher(this);
     },
 
-    enable: function() {
+    _ensureResidentSource: function() {
+        if (this._residentSource)
+            return;
+
         this._residentSource = new AutorunResidentSource(this);
+        let destroyId = this._residentSource.connect('destroy', Lang.bind(this, function() {
+            this._residentSource.disconnect(destroyId);
+            this._residentSource = null;
+        }));
+    },
+
+    enable: function() {
         this._scanMounts();
 
         this._mountAddedId = this._volumeMonitor.connect('mount-added', Lang.bind(this, this._onMountAdded));
@@ -169,6 +179,7 @@ const AutorunManager = new Lang.Class({
         mounts.forEach(Lang.bind(this, function (mount) {
             let discoverer = new ContentTypeDiscoverer(Lang.bind (this, 
                 function (mount, apps) {
+                    this._ensureResidentSource();
                     this._residentSource.addMount(mount, apps);
                 }));
 
@@ -185,6 +196,7 @@ const AutorunManager = new Lang.Class({
         let discoverer = new ContentTypeDiscoverer(Lang.bind (this,
             function (mount, apps, contentTypes) {
                 this._transDispatcher.addMount(mount, apps, contentTypes);
+                this._ensureResidentSource();
                 this._residentSource.addMount(mount, apps);
             }));
 
@@ -193,7 +205,8 @@ const AutorunManager = new Lang.Class({
 
     _onMountRemoved: function(monitor, mount) {
         this._transDispatcher.removeMount(mount);
-        this._residentSource.removeMount(mount);
+        if (this._residentSource)
+            this._residentSource.removeMount(mount);
     },
 
     ejectMount: function(mount) {
@@ -266,8 +279,8 @@ const AutorunResidentSource = new Lang.Class({
 
         this._mounts = [];
 
-        this._notification = new AutorunResidentNotification(this._manager, this);
         this._manager = manager;
+        this._notification = new AutorunResidentNotification(this._manager, this);
     },
 
     addMount: function(mount, apps) {
@@ -384,7 +397,7 @@ const AutorunResidentNotification = new Lang.Class({
 
         // now connect signals
         mountButton.connect('clicked', Lang.bind(this, function(actor, event) {
-            this._manager.startAppForMount(apps[0], mount);
+            startAppForMount(apps[0], mount);
         }));
 
         ejectButton.connect('clicked', Lang.bind(this, function() {